package mlz.c_map;

import java.util.*;

/* 集合嵌套(Collection + Map)
在程序中记住如下省份和其对应的城市信息，记录成功后.
浙江省=杭州市,宁波市,温州市,嘉兴市,绍兴市,金华市
江苏省=南京市,扬州市,苏州市,无锡市,常州市
河北省=石家庄市,唐山市,邢台市,保定市,张家口市
 */
public class MapDemo07 {
    public static void main(String[] args) {
        //1.定义一个Map集合用于存储全部的省份信息, 和对应的城市信息
        HashMap<String, List<String>> map = new HashMap<>();

        //城市信息已经添加完毕
        List<String> cities1 = new ArrayList<>();
        Collections.addAll(cities1,"杭州市","宁波市","温州市","嘉兴市","绍兴市","金华市");

        List<String> cities2 = new ArrayList<>();
        Collections.addAll(cities2,"南京市","扬州市","苏州市","无锡市","常州市");

        List<String> cities3 = new ArrayList<>();
        Collections.addAll(cities3,"石家庄市","唐山市","邢台市","保定市","张家口市");

        //省份和城市一一对应
        map.put("浙江省",cities1);
        map.put("江苏省",cities2);
        map.put("河北省",cities3);

        map.forEach((p,c) -> System.out.println(p + "---->" + c));


    }
}




















